package cn.wx;

import cn.wx.common.properties.WxProperties;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage;
import org.apache.commons.lang3.StringUtils;

/**
 * 内存存储
 *
 * @author: sunshaoping
 * @date: Create by in 6:38 下午 2020/5/25
 */
public class WxOpenInMemoryConfigStorageFactory implements WxOpenConfigStorageFactory<WxProperties> {
    @Override
    public WxOpenConfigStorage create(WxProperties properties) {
        WxOpenInMemoryConfigStorage config = new WxOpenInMemoryConfigStorage();
        config.setComponentAppId(StringUtils.trimToNull(properties.getAppId()));
        config.setComponentAppSecret(StringUtils.trimToNull(properties.getSecret()));
        config.setComponentAesKey(StringUtils.trimToNull(properties.getAesKey()));
        config.setComponentToken(StringUtils.trimToNull(properties.getToken()));
        return config;

    }
}
